<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #box span{
            color: red;
            font-size: 20px;
            font-weight: 700;
            position: absolute;
        }
    </style>
</head>
<body>
    <h1>蛇形文字</h1>

    <hr>

    <div id="box">
    <span>咸</span>
    <span>鱼</span>
    <span>的</span>
    <span>生</span>
    <span>活</span>
    <span>!</span>
    </div>

    <script>
        var spans = document.getElementById('box').getElementsByTagName('span');

        //绑定鼠标移动事件
        
        window.onmousemove = function(e){
            for (var i = 0; i < spans.length; i++){
                (function(i){
                    setTimeout(function(){
                        spans[i].style.left = e.x + (i*25) + 'px';
                        spans[i].style.top = e.y + 'px';
                    }, i*50);
                })(i);
            }
        }
    </script>
</body>
</html>